﻿<Window x:Class="ConsoleHoster.View.Popups.ProjectsAndCommandsSelector"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:uc="clr-namespace:ConsoleHoster.View.Controls"
        xmlns:cv="clr-namespace:ConsoleHoster.View.Converters"
        xmlns:pp="clr-namespace:ConsoleHoster.View.Popups"
        Title="{Binding Path=WindowTitle}" MinHeight="100" MinWidth="200" Width="400" Height="300" Style="{DynamicResource PopupStyle}" WindowStartupLocation="CenterOwner">
    <Window.Resources>
        <cv:ObjectToVisibilityConverter x:Key="cvObjectToVisibilityConverter" />
    </Window.Resources>
    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <GroupBox Header="Projects" Grid.RowSpan="2" Margin="0, 0, 5, 0" Padding="0, 3, 0, 0">
                <ListView ItemsSource="{Binding Path=Projects}" SelectedValue="{Binding Path=SelectedProject, Mode=TwoWay}" HorizontalAlignment="Stretch">
                    <ListView.View>
                        <GridView AllowsColumnReorder="False" ColumnHeaderContainerStyle="{DynamicResource ResourceKey=gridViewHiddenHeaderStyle}">
                            <GridViewColumn Width="Auto">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox IsChecked="{Binding Path=Item2, Mode=TwoWay}" Margin="0, 0, 3, 0" Height="13" Width="13" VerticalContentAlignment="Center"  BorderThickness="0" Cursor="Hand" ToolTip="Remove project..." />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn DisplayMemberBinding="{Binding Path=Item1}"/>
                        </GridView>
                    </ListView.View>
                </ListView>
            </GroupBox>

            <GroupBox Header="Commands" Grid.Column="1" Margin="0, 0, 5, 0" Padding="0, 3, 0, 0" Visibility="{Binding Path=SelectedProject, Converter={StaticResource ResourceKey=cvObjectToVisibilityConverter}}">
                <ListView ItemsSource="{Binding Path=SelectedProjectCommands}" HorizontalAlignment="Stretch">
                    <ListView.View>
                        <GridView AllowsColumnReorder="False" ColumnHeaderContainerStyle="{DynamicResource ResourceKey=gridViewHiddenHeaderStyle}">
                            <GridViewColumn Width="Auto">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox IsChecked="{Binding Path=Item2, Mode=TwoWay}" Margin="0, 0, 3, 0" Height="13" Width="13" VerticalContentAlignment="Center"  BorderThickness="0" Cursor="Hand" ToolTip="Remove project..." />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn DisplayMemberBinding="{Binding Path=Item1}"/>
                        </GridView>
                    </ListView.View>
                </ListView>
            </GroupBox>
        </Grid>

        <StackPanel Orientation="Horizontal" Grid.Row="1" Margin="0, 5, 0, 0" HorizontalAlignment="Center" >
            <Button x:Name="btnSave" Content="{Binding Path=SaveButtonTitle}" Width="100" Click="btnSave_Click" Margin="0, 0, 0, 0" Cursor="Hand" />
            <Button x:Name="btnCancel" Content="Cancel" Width="100" Margin="3, 0, 0, 0" Click="btnCancel_Click" Cursor="Hand" />
        </StackPanel>
    </Grid>
</Window>
